//
//  LoginView.m
//  DiscountClub
//
//  Created by Philip Chew on 28/2/12.
//  Copyright (c) 2012 articwind@gmail.com. All rights reserved.
//

#import "LoginViewController.h"

@implementation LoginViewController
@synthesize userEmail, userPassword, mySelector;

- (id)initWithNotification:(NSString *)myCallerSelector 
{
	if(([self initWithNibName:@"LoginViewController" bundle:nil])) {
		self.title = @"Login to Discount Club";
		self.mySelector = myCallerSelector;
		self.navigationItem.hidesBackButton = YES;
	}
	
	return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - UI Events
- (IBAction) onClick_Login
{
	[self notifyCaller];
}

- (IBAction) userEmailNext
{
	[userEmail resignFirstResponder];
	[userPassword becomeFirstResponder];
}

- (IBAction) onClick_Outside
{
	[userEmail resignFirstResponder];
	[userPassword resignFirstResponder];
}

#pragma mark - Private Methods
- (void) notifyCaller 
{
	[[NSNotificationCenter defaultCenter] postNotificationName:self.mySelector object:self];
	[self.navigationController popViewControllerAnimated:YES];
}

@end
